Rebooting IcoTera i4882-00 using python

from http.cookiejar import MozillaCookieJar
import requests

cookies = MozillaCookieJar()

with requests.Session() as session:
  session.cookies = cookies

  # Log in
  headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0',
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.5',
    # 'Accept-Encoding': 'gzip, deflate',
    'Content-Type': 'text/plain;charset=UTF-8',
    'Origin': 'http://192.168.0.1',
    'Connection': 'keep-alive',
    'Referer': 'http://192.168.0.1/',
  }
  data = 'curpg=null&req=log_in&username=admin&password=YOURPASSWORDHERE&'

  response = session.post('http://192.168.0.1/index.cgi', headers=headers, data=data)

  # reboot the router
  headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0',
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.5',
    # 'Accept-Encoding': 'gzip, deflate',
    'Content-Type': 'text/plain;charset=UTF-8',
    'Origin': 'http://192.168.0.1',
    'Connection': 'keep-alive',
    'Referer': 'http://192.168.0.1/',
  }

  data = 'curpg=diagnostic.reboot&curmenu=DIAGNOSTIC/RESTART&req=reboot&'

  response = session.post('http://192.168.0.1/index.cgi', headers=headers, data=data)
  print(response.text)

Last modified: Wed Sep 4 16:06:43 2024